﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using ExtBusiness.CommonBusiness;
using ExtBusiness;
using ExtBusiness.FlowOperation;
using System.Configuration;

public partial class frmMainNew : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (UserName != null)
            {
                string strMsg = "<script>";

                //获取设置标题头
                strMsg += "function initWinInfo(){";
                //设置待办件的地址
                strMsg += "addTab(strFirstUrl,strFirstUrlName);";

                strMsg += string.Format("loadTitle('divCenter','业务办公区【欢迎您，{0}，今天是{1}】');", UserName, DateTime.Now.ToShortDateString());

                //获取待接收短消息 
                string strPopContent = "<table>";
                DataTable dtReturn = new DataTable();

                string strSlhjCookie = string.Empty;//寄存受理环节待受理和补正的cookie
                if (GroupId == ConfigurationManager.AppSettings["TxGroupId"])
                {
                    ClsSubmitInfo clsSubmit = new ClsSubmitInfo();
                    dtReturn = clsSubmit.GetBusinessInfo(UserId, "", "", "", "0");//待预审
                    strPopContent += string.Format("<tr><td><a href=javascript:addTab('office/OnlineTask.aspx?Business=0','网上申报受理')>您有{0}条待受理网上办件</a></td></tr>", dtReturn.Rows.Count);
                    //获取待预审信息(存放cookie中)
                    strMsg += string.Format("setCookie('dys_gs', '{0}');",dtReturn.Rows.Count);
                    strSlhjCookie += "getCookie('dys_gs')";

                    dtReturn = clsSubmit.GetBusinessInfo(UserId, "", "", "", "1");//补正补齐
                    strPopContent += string.Format("<tr><td><a href=javascript:addTab('office/OnlineTask.aspx?Business=1','补正件重新受理')>您有{0}条待受理补正件</a></td></tr>", dtReturn.Rows.Count);
                    //获取待补正信息(存放cookie中)
                    strMsg += string.Format("setCookie('dbz_gs', '{0}');", dtReturn.Rows.Count);
                    strSlhjCookie += "+\"|\"+getCookie('dbz_gs')+\"|\"+";
                }

                RequestFlowOperation flowOperation = new RequestFlowOperation();
                dtReturn = flowOperation.AppearTaskInStep(UserId, "",0);//待办件
                strPopContent += string.Format("<tr><td><a href=javascript:addTab('{1}','我的待办件')>您有{0}条待办件</a></td></tr>", dtReturn.Rows.Count, ConfigurationManager.AppSettings["dbsxUrl"]);
                //获取待办信息(存放cookie中)
                strMsg += string.Format("setCookie('dbj_gs', '{0}');", dtReturn.Rows.Count);

                Message msg = new Message();
                dtReturn = msg.GetReceiveMessage(UserName, "", "", "");
                strPopContent += string.Format("<tr><td><a href=javascript:addTab('ManageInside/getMessage.aspx','接收即时消息')>您有{0}条短消息</a></td></tr>", dtReturn.Rows.Count);

                ////获取来见查阅信息
                //dtReturn = msg.GetLjcy(RealUserId);
                //strPopContent += string.Format("<tr><td><a href=javascript:addTab('ManageInside/SubBrowseFile.aspx','来件查阅')>您有{0}个待查阅文件</a></td></tr>", dtReturn.Rows.Count);

                strPopContent += "</table>";
                strMsg += string.Format("loadMsg(\"{0}\");", strPopContent);                
                strMsg += "}";

                //定义定时获取待办事件
                string strGetDaiban = "function GetDaiBanInfo(){WebService(\"WebService/JqueryService.asmx/GetDaiBan\", AppearDaiBan, \"{'strUserId':'" + UserId + "','strOldDbCount':'\"+" + strSlhjCookie + "getCookie('dbj_gs')+\"'}\");}";
                strMsg += strGetDaiban;

                //脚本结束信息
                strMsg += "</script>";

                Response.Write(strMsg);
                //Common.WindowAppear.ExecuteScript(this.Page, strMsg);
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "setTitle", strMsg);                
            }
        }
    }
}
